//
//  MainViewController.swift
//  新浪微博
//
//  Created by seteny on 16/7/9.
//  Copyright © 2016年 seteny. All rights reserved.
//

import UIKit

class MainViewController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()

       view.backgroundColor = UIColor.yellowColor()
    
    
    
        addChildViewController(HomeTableViewController(), title: "首页", imageName: "tabbar_home")
        
        addChildViewController(MessageTableViewController(), title: "消息", imageName: "tabbar_message_center")
        
        addChildViewController(DiscoverTableViewController(), title: "发现", imageName: "tabbar_discover")
        
        addChildViewController(ProfileTableViewController(), title: "我的", imageName: "tabbar_profile")
    
    
    
    
    
    
    
    
    
    }
    
    
    
    
     func addChildViewController(childController: UIViewController, title: String, imageName: String) {
        
        //标题
        childController.title = title
        
        childController.tabBarItem.image = UIImage(named: imageName)
        //设置选中显示图片 并 渲染图片
        childController.tabBarItem.selectedImage = UIImage(named: imageName + "_selected")?.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal)
        
        //设置字体
        childController.tabBarItem.setTitleTextAttributes([NSForegroundColorAttributeName : UIColor.orangeColor()], forState: .Selected)//颜色
        childController.tabBarItem.setTitleTextAttributes([NSFontAttributeName : UIFont.systemFontOfSize(14)], forState: .Normal)//大小
        
        
        let nav = UINavigationController(rootViewController: childController)
        
        addChildViewController(nav)
    }
    
    
    

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    


}
